package cn.longge.mapper;

import cn.longge.entity.SysResource;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
@CacheNamespace(blocking = true)
public interface SysResourceMapper extends Mapper<SysResource> {

    @Options
    @Select("select sr.id,sr.name from sys_resource sr,sys_role_resource srr \n" +
            "where sr.del_flag = '0'\n" +
            "and sr.id = srr.resource_id \n" +
            "and srr.role_id = #{rid}")
    public List<SysResource> selectByRid(Long rid);

    @Select("SELECT sr.* FROM sys_user_role sur,sys_role_resource srr,sys_resource sr\n" +
            "where sr.del_flag = '0'\n" +
            "and sur.user_id = #{uid} \n" +
            "and sur.role_id = srr.role_id \n" +
            "and sr.id = srr.resource_id ORDER BY id desc")
    public List<SysResource> selectByUid(Long uid);

    @Select("select * from sys_resource where type = '0' and url <> ''")
    public List<SysResource> selectResource();



}